/*
 * @Author: Lin Hongwei
 * @Date: 2022-10-09 19:58:22
 * @LastEditTime: 2022-10-09 21:00:26
 * @LastEditors: Lin Hongwei
 * @email: 1365755396@qq.com
 * @CSDN: https://blog.csdn.net/weixin_45429409
 * @Description: 创建看板
 */
import { Input } from "antd";
import { useState } from "react";
import { useAddKanban } from "../../../api/kanban";
import { Container } from "./kanban-column";
import { useKanbanQueryKey, useProjectIdInUrl } from "./utils";

export const CreateKanBanView = () => {
  const [name, setName] = useState("");
  const projectId = useProjectIdInUrl();
  const { mutateAsync, isLoading } = useAddKanban(useKanbanQueryKey());
  const onSubmitInput = () => {
    if (isLoading) return;
    mutateAsync({
      name,
      projectId,
    }).then(() => setName(""));
  };
  return (
    <Container>
      <Input
        placeholder="新建看板名称"
        value={name}
        onPressEnter={onSubmitInput}
        onChange={(e) => setName(e.target.value)}
      />
    </Container>
  );
};
